<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link href="${aier_css_url}jq/jq.css" rel="Stylesheet" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}text.css" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}enhanced.css" />
<link rel="stylesheet" href="${aier_css_url}school/ma.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>

<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}custominput.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}text.js"></script>
<title>菜谱条件管理</title>

<script type="text/javascript">

$(document).ready(function(){          
	$("#gongyiinfo").jqGrid({                
		url:'${aier_url}${aier_urijs}caipu_loadGongYi${aier_suffix}',                
		datatype:"json",                
		mtype:'GET', 
		height:'240',
		width:'220',                 
		colNames:['名称','数量','操作','id'],                
		colModel:[                    
		{name:'gy_name',index:'gy_name',width:100,align:'center', sortable:false},
		{name:'gy_num',index:'gy_num',width:60,align:'center', sortable:false},
		{name:'option',index:'gy_id',width:60,align:'center', sortable:false},
		{name:'gy_id',index:'gy_id',hidden:true}
		],
		//autowidth:true,
		jsonReader: {
			root:"gongyiList",
			page: "page",
			total: "page_count",
			records : "count",
			repeatitems: false
		},
		pager: jQuery("#gongyipage"),
		prmNames : {page:"page",sort: "sort"},
		rowNum: 10,
		hidegrid: false,
		viewrecords: true,
		caption: '工艺',
		gridComplete:function(){
			var ids=jQuery("#gongyiinfo").jqGrid('getDataIDs');
			for(var i=0; i<ids.length; i++){
				var id=ids[i];   
				del = "<a href='javascript:;' class='jqtrow' onclick='delGY(" + id + ")'>删除</a>";
				jQuery("#gongyiinfo").jqGrid('setRowData', ids[i], {option:del});
			}
		}
	}).navGrid("#gongyipage", { edit: false, add: false, del: false, search: false });

	$("#nanduinfo").jqGrid({                
		url:'${aier_url}${aier_urijs}caipu_loadNanDu${aier_suffix}',                
		datatype:"json",                
		mtype:'GET', 
		height:'240',
		width:'220',                 
		colNames:['名称','数量','操作','id'],                
		colModel:[                    
		{name:'nd_name',index:'nd_name',width:200,align:'center', sortable:false},
		{name:'nd_num',index:'nd_num',width:60,align:'center', sortable:false},
		{name:'option',index:'nd_id',width:60,align:'center', sortable:false},
		{name:'nd_id',index:'nd_id',hidden:true}
		],
		//autowidth:true,
		jsonReader: {
			root:"nanduList",
			page: "page",
			total: "page_count",
			records : "count",
			repeatitems: false
		},
		pager: jQuery("#nandupage"),
		prmNames : {page:"page",sort: "sort"},
		rowNum: 10,
		hidegrid: false,
		viewrecords: true,
		caption: '难度',
		gridComplete:function(){
			var ids=jQuery("#nanduinfo").jqGrid('getDataIDs');
			for(var i=0; i<ids.length; i++){
				var id=ids[i];   
				del = "<a href='javascript:;' class='jqtrow' onclick='delND(" + id + ")'>删除</a>";
				jQuery("#nanduinfo").jqGrid('setRowData', ids[i], {option:del});
			}
		}
	}).navGrid("#nandupage", { edit: false, add: false, del: false, search: false });
	
	$("#caixiinfo").jqGrid({                
		url:'${aier_url}${aier_urijs}caipu_loadCaiXi${aier_suffix}',                
		datatype:"json",                
		mtype:'GET', 
		height:'240',
		width:'220',                 
		colNames:['名称','数量','操作','id'],                
		colModel:[                    
		{name:'cx_name',index:'cx_name',width:200,align:'center', sortable:false},
		{name:'cx_num',index:'cx_num',width:60,align:'center', sortable:false},
		{name:'option',index:'cx_id',width:60,align:'center', sortable:false},
		{name:'cx_id',index:'cx_id',hidden:true}
		],
		//autowidth:true,
		jsonReader: {
			root:"caixiList",
			page: "page",
			total: "page_count",
			records : "count",
			repeatitems: false
		},
		pager: jQuery("#caixipage"),
		prmNames : {page:"page",sort: "sort"},
		rowNum: 10,
		hidegrid: false,
		viewrecords: true,
		caption: '板块',
		gridComplete:function(){
			var ids=jQuery("#caixiinfo").jqGrid('getDataIDs');
			for(var i=0; i<ids.length; i++){
				var id=ids[i];   
				del = "<a href='javascript:;' class='jqtrow' onclick='delCX(" + id + ")'>删除</a>";
				jQuery("#caixiinfo").jqGrid('setRowData', ids[i], {option:del});
			}
		}
	}).navGrid("#caixipage", { edit: false, add: false, del: false, search: false });
	
	$("#kouweiinfo").jqGrid({                
		url:'${aier_url}${aier_urijs}caipu_loadKouWei${aier_suffix}',                
		datatype:"json",                
		mtype:'GET', 
		height:'240',
		width:'220',                 
		colNames:['名称','数量','操作','id'],                
		colModel:[                    
		{name:'kw_name',index:'kw_name',width:200,align:'center', sortable:false},
		{name:'kw_num',index:'kw_num',width:60,align:'center', sortable:false},
		{name:'option',index:'kw_id',width:60,align:'center', sortable:false},
		{name:'kw_id',index:'kw_id',hidden:true}
		],
		//autowidth:true,
		jsonReader: {
			root:"kouweiList",
			page: "page",
			total: "page_count",
			records : "count",
			repeatitems: false
		},
		pager: jQuery("#kouweipage"),
		prmNames : {page:"page",sort: "sort"},
		rowNum: 10,
		hidegrid: false,
		viewrecords: true,
		caption: '口味',
		gridComplete:function(){
			var ids=jQuery("#kouweiinfo").jqGrid('getDataIDs');
			for(var i=0; i<ids.length; i++){
				var id=ids[i];   
				del = "<a href='javascript:;' class='jqtrow' onclick='delKW(" + id + ")'>删除</a>";
				jQuery("#kouweiinfo").jqGrid('setRowData', ids[i], {option:del});
			}
		}
	}).navGrid("#kouweipage", { edit: false, add: false, del: false, search: false });
});

// 删除工艺
function delGY(id){
	var funadd = function(data1){
		if(1==data1.s){
			 $().message("删除成功!");
			 $("#gongyiinfo").trigger("reloadGrid");
		}else{
			 $().message("删除失败!");
		}
	};
	exeAjax(ajaxUrl("${aier_url}${aier_urijs}caipu_deleteGY${aier_suffix}"), funadd, 
	{"gy_id_del" :jQuery("#gongyiinfo").jqGrid('getRowData', id).gy_id});
}

// 删除难度
function delND(id){
	var funadd = function(data1){
		if(1==data1.s){
			 $().message("删除成功!");
			 $("#nanduinfo").trigger("reloadGrid");
		}else{
			 $().message("删除失败!");
		}
	};
	exeAjax(ajaxUrl("${aier_url}${aier_urijs}caipu_deleteND${aier_suffix}"), funadd, 
	{"nd_id_del" :jQuery("#nanduinfo").jqGrid('getRowData', id).nd_id});
}

// 删除菜系
function delCX(id){
	var funadd = function(data1){
		if(1==data1.s){
			 $().message("删除成功!");
			 $("#caixiinfo").trigger("reloadGrid");
		}else{
			 $().message("删除失败!");
		}
	};
	exeAjax(ajaxUrl("${aier_url}${aier_urijs}caipu_deleteCX${aier_suffix}"), funadd, 
	{"cx_id_del" :jQuery("#caixiinfo").jqGrid('getRowData', id).cx_id});
}

// 删除口味
function delKW(id){
	var funadd = function(data1){
		if(1==data1.s){
			 $().message("删除成功!");
			 $("#kouweiinfo").trigger("reloadGrid");
		}else{
			 $().message("删除失败!");
		}
	};
	exeAjax(ajaxUrl("${aier_url}${aier_urijs}caipu_deleteKW${aier_suffix}"), funadd, 
	{"kw_id_del" :jQuery("#kouweiinfo").jqGrid('getRowData', id).kw_id});
}
</script>
</head>
<body>

				<div id="tabs">
					<div id="tabs-1" style="height: 500px;">
						<div class="d_content">
							<div style="margin-top: 30px;margin-left: -50px;">
								<div class="d_scnOut">
									<div class="d_scname">
										<label>工艺:</label>
									</div>
									<div class="d_sctext">
										<input id="gy_name_add" type="text">
									</div>
									<button onclick="addgy()" 
										style="margin-top: 25px;margin-left: 185px;"
										class="b_maSel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" 
										role="button" aria-disabled="false">
										<span class="ui-button-text">添加工艺</span>
									</button>
									<div style="margin-top: 5px;margin-left: 50px;">
										<table id="gongyiinfo"></table>
										<div id="gongyipage"></div>
									</div>									
								</div>
							</div>
							<div style="margin-top: -40px;margin-left: 230px;">
								<div class="d_scnOut">
									<div class="d_scname">
										<label>难度:</label>
									</div>
									<div class="d_sctext">
										<input id="nd_name_add" type="text">
									</div>
								</div>	
								<button onclick="addnd()" 
									style="margin-top: 5px;margin-left: 185px;"
									class="b_maSel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" 
									role="button" aria-disabled="false">
									<span class="ui-button-text">添加难度</span>
								</button>
								<div style="margin-top: 5px;margin-left: 50px;">
									<table id="nanduinfo"></table>
									<div id="nandupage"></div>
								</div>
													
							</div>
							<div style="margin-top:-395px;margin-left: 480px;">
								<div class="d_scnOut">
									<div class="d_scname">
										<label>板块:</label>
									</div>
									<div class="d_sctext">
										<input id="cx_name_add" type="text">
									</div>
								</div>	
								<button onclick="addcx()" 
									style="margin-top: 5px;margin-left: 185px;"
									class="b_maSel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" 
									role="button" aria-disabled="false">
									<span class="ui-button-text">添加板块</span>
								</button>
								<div style="margin-top: 5px;margin-left: 50px;">
									<table id="caixiinfo"></table>
									<div id="caixipage"></div>
								</div>
													
							</div>
							<div style="margin-top: -395px;margin-left: 730px;">
								<div class="d_scnOut">
									<div class="d_scname">
										<label>口味:</label>
									</div>
									<div class="d_sctext">
										<input id="kw_name_add" type="text">
									</div>
								</div>		
								<button onclick="addkw()" 
									style="margin-top: 5px;margin-left: 185px;"
									class="b_maSel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" 
									role="button" aria-disabled="false">
									<span class="ui-button-text">添加口味</span>
								</button>
								<div style="margin-top: 5px;margin-left: 50px;">
									<table id="kouweiinfo"></table>
									<div id="kouweipage"></div>
								</div>
												
							</div>
							
						</div>
					</div>
				</div>
</body>
<script type="text/javascript">
$("#tabs").tabs();
// 添加工艺
function addgy(){
	var gy_name_add = $("#gy_name_add").val();
	if(gy_name_add.trim()==""){
		$().message("请输入要添加的工艺名称");
		return
	}
	var fun = function(data) {
		if(1==data.s){
			$().message("添加工艺成功!");
			$("#gongyiinfo").trigger("reloadGrid");
		}else{
			$().message("添加工艺失败,"+data.error_info);
		}
	};
	exeAjax(ajaxUrl("${aier_url}${aier_urijs}caipu_addGongYi${aier_suffix}"), fun, 
		{"gy_name_add" : gy_name_add});
}
// 添加难度
function addnd(){
	var nd_name_add = $("#nd_name_add").val();
	if(nd_name_add.trim()==""){
		$().message("请输入要添加的难度名称");
		return
	}
	var fun = function(data) {
		if(1==data.s){
			$().message("添加难度成功!");
			$("#nanduinfo").trigger("reloadGrid");
		}else{
			$().message("添加难度失败,"+data.error_info);
		}
	};
	exeAjax(ajaxUrl("${aier_url}${aier_urijs}caipu_addNanDu${aier_suffix}"), fun, 
		{"nd_name_add" : nd_name_add});
}
// 添加菜系
function addcx(){
	var cx_name_add = $("#cx_name_add").val();
	if(cx_name_add.trim()==""){
		$().message("请输入要添加的板块名称");
		return
	}
	var fun = function(data) {
		if(1==data.s){
			$().message("添加板块成功!");
			$("#caixiinfo").trigger("reloadGrid");
		}else{
			$().message("添加板块失败,"+data.error_info);
		}
	};
	exeAjax(ajaxUrl("${aier_url}${aier_urijs}caipu_addCaiXi${aier_suffix}"), fun, 
		{"cx_name_add" : cx_name_add});
}
// 添加口味
function addkw(){
	var kw_name_add = $("#kw_name_add").val();
	if(kw_name_add.trim()==""){
		$().message("请输入要添加的口味名称");
		return
	}
	var fun = function(data) {
		if(1==data.s){
			$().message("添加口味成功!");
			$("#kouweiinfo").trigger("reloadGrid");
		}else{
			$().message("添加口味失败,"+data.error_info);
		}
	};
	exeAjax(ajaxUrl("${aier_url}${aier_urijs}caipu_addKouWei${aier_suffix}"), fun, 
		{"kw_name_add" : kw_name_add});
}
	//$(".chosen").chosen();
	
	
	
	
</script>

</html>